package cn.mys.tissue.model.dao.maildao;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import cn.mys.tissue.model.entity.mail.Mailnumber;
import cn.mys.tissue.model.entity.user.User;

public interface MailnumberDao extends PagingAndSortingRepository<Mailnumber, Long>{
	//根据状态和user来找account
	Page<Mailnumber> findByMailuserId(User user,Pageable page);

	//根据用户和type排序account
	Page<Mailnumber> findByMailuserIdOrderByMailType(User user,Pageable page);

	//根据用户和status排序account
	Page<Mailnumber> findByMailuserIdOrderByStatus(User user,Pageable page);

	//根据用户和创建时间排序account
	Page<Mailnumber> findByMailuserIdOrderByMailCreateTimeDesc(User user,Pageable page);

	//根据用户和发件别名模糊查找account
	@Query("select mn from Mailnumber mn where  mn.mailUserName like %:val% and mn.mailuserId=:tu ")
	Page<Mailnumber> findByMailUserNameLikeAndMailuserId(@Param("val")String val,@Param("tu") User tu,Pageable page);
	
	List<Mailnumber> findByStatusAndMailuserId(Long status,User u);

}
